home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Collections: MegaDisc
/
MegaDisc 06 (1988)(MegaDisc Digital Publishing)(AU)[m][WB].zip
/
MegaDisc 06 (1988)(MegaDisc Digital Publishing)(AU)[m][WB].adf
/
FEEDBACK
/
GAMES-INTRO
< prev
next >
Wrap
Text File
|
1988-03-27
|
20KB
|
454 lines
AN AMIGABASIC/C TUTORIAL DISK BY GARY O'CONNOR
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ED. NOTE: Gary sent in a disk full of very useful and informative
explanations and tutorials and programs illustrating different
aspects of programming. He has a very clear way of explaining
complex problems, and anyone interested in programming on the
Amiga would do well to have a look at it. He's kindly let us send
it out as a Theme Disk, and may well send more in as a series.
Below is his INTRO which explains some of the games on his disk.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This disc contains a game, a demo programme and two Utilities
that I've written in AmigaBASIC, that I thought you might find
interesting.
There is a `C' interpretation of the game to demonstrate the
difference in programme execution times. The 'C' Code is included for
your perusal.
They all use SYSTEM 1.2 and will not operate on 1.1 as they employ
the larger screen sizes available with 1.2.
The game was written as an early exercise in AmigaBASIC.
This disc has all the necessary BITMAPS in the Libs directory but I
have included six more in the main directory, under icons, which I thought
you might you might find useful, if you don't already have them. All the
programmes on this disc assume that you have the necessary BitMaps in your
libs directory.
Each of the programmes demonstrate the use of `System Sub-Routines'.
These routines have, generally, been used instead of standard AmigaBASIC
commands wherever it is possible. You'll find this to be good practice for
your inevitable conversion to `C', in fact `C' code will no longer look
nearly as weird as it used to.
On this disc you will find extensive use of; DiskFonts, text
positioning using `CALL Move&', changing between `JAM1' and `JAM2' modes
using `CALL SetDrMd&', scrolling using `CALL ScrollRaster&', changeing
foreground and background colours using `CALL SetAPen&' and SetBPen&'
along with other `CALL's to the Intuition Library and so on.
I believe that a close investigation of the contents of this disc
will answer some of those questions that you, inevitably, ask yourself
when you are beginning to write programs such as `How do they do that?'
The `Text Demo' programme will explain how you can include text in
your graphics without wiping out some of your artwork, it will show you
how to position your text in your graphics rather than having to build
your graphics around your text. It will show you how to make `Shadowed
Text' and how to `Fade' text, even how to make text move around the
screen. It will demonstrate the wonders of `Scrolling' in a million
different directions using AmigaBASIC with explanations in English.
The `ASCII.ref' Utility will very neatly tell you what `Code' is
returned to your programme when you use the `INKEY$' function, at the
same time displaying the `On Screen' representation of that, returned,
value. It also demonstrates the use of `Disk Fonts' and `MENU's,
allowing you, via the `MENU' function to choose any of the various Fonts
contained on your disc.
It is possible to write a routine to search your disk for the
available fonts and then place them in your `MENU' selection. This has
been the method used for this Utility and that makes it reasonably
`Transportable' (meaning you can just copy the programme to any disc and
it will return the available Fonts. Provided you have the necessary
BitMaps in the libs directory of that disc).
****************************************************************************
CAUTION FOR ASCII.ref PROGRAMME:::::::
This programme loads all the available fonts into memory and can
therefore be `memory intensive'. This disc has twenty eight disc based
fonts and two resident fonts. That is the maximum a 512k AMIGA seems to
handle and still run the programme. You WILL need more memory if you
have more fonts.
THE ONLY WAY IT WILL RUN ON THIS DISC is if you drag it's ICON out of the
disc window and close it (the disc window on the workbench) before you
attempt to run it.
That would not be necessary on a standard disc, as it has less fonts.
*****************************************************************************
You will find complete descriptions of each programme listed below.
I hope you can get something out of it. I offer it all freely in the
hope of promoting an interest in programming and to answer some of those
nagging, generally unanswerable, questions.
CAUTION::::
Some of these programs use the Font called `pcfont'. It is not a
standard Font, so, if you wish to use these programs on other discs, you
will have to do one of two things....
1. Change the programs so that they call the standard `topazfont'
or
2. Copy the pcfont from this disc to the one you will be using.
To do that, follow these instructions .....
If you have two disc drives put this disc in df0: and `YOUR DISC'
in df1:. Boot with this disc and enter the cli from it, then type
MAKEDIR df1:libs/pcfont
COPY df0:libs/pcfont to df1:libs/pcfont all
COPY df0:libs/pcfont.font to df1:libs/pcfont.font
If you have one Disc Drive, Boot with this disc and enter the
cli.
Then type
EXECUTE quickram
Wait till the "ALL DONE NOW" appears, then continue typing the
following
MAKEDIR ram:pcfont
COPY df0:libs/pcfont to ram:pcfont all
COPY df0:libs/pcfont.font to ram:
Now put `YOUR DISC' in df0: and type
MAKEDIR df0:libs/pcfont
COPY ram:pcfont to df0:libs/pcfont all
COPY ram:pcfont.font to df0:libs
Quickram is an `executeable' batch file, in the `S' directory on
this disc, that creates a `ram disc' with a `C' directory and assigns
all calls to `C' to the ram:c. This has the effect of reducing disk
swapping to a minimum.
There are two other associated `batch files' in the `S' directory.
One is called `RAMIT' the other is called `CLEARIT'.
RAMIT will copy the action of QUICKRAM but puts the entire `C'
directory into ram:. CLEARIT clears the ramdisc of its `C' directory and
re-assigns `C' to SYS:C, returning everything to normality. To use
CLEARIT, assuming you have been using QUICKRAM or RAMIT and you are
still in the CLI, type the following.....
SYS:c/execute CLEARIT
Your CLI will now act normally and QUICKRAM/RAMIT will have been
removed from the ram: disc.
*****************************************************************************
Text Demo
(Requires Sys 1.2,`graphics',`diskfont' and `intuition' bmaps and
`pcfont')
I wrote Text Demo whilst I was teaching my kids how to use the
System Librarys for the purpose of better placement of text in Graphics
programmes. It, sort of, evolved as we were going along.
I have since found that everyone who watches it is intrigued and,
that those interested in programming, find it informative. Amigans into,
or only capable of, AmigaBASIC rush off to adjust their programmes with
new Title Pages or to make that text fit into their graphics, rather
than build their graphics around the limitations of the `LOCATE' command
and the JAM2 Mode.
When I get a programme from one of my fellow `Computerists' I now
see scrolling screens and fading text, text coming from all directions
and all of it perfectly placed within their graphics.
I make no pretence to having written the `Perfect Text Demo', it's
far from that, but it is, at least, inspirational and gives BASIC
programmers a feeling of accomplishment that's hard to explain to
someone who programmes in `C' or `68000 Machine Language'. It also
begins to give anyone who uses the routines contained in the Librarys,
an understanding of `C' programming which will stand them in good stead
when they finally convert.
*****************************************************************************
ASCII.ref
(Requires Sys 1.2,`graphics.bmap' and `diskfont.bmap')
This UTILITY programme was designed to display, on screen, the ASCII
value of any key pressed. At least that's how it started out.
I, accidentally, discovered that there was a difference in the
`graphic' output between `PC.font' and `TOPAZ.font' for the functional
keys, (Run the programme and press the `DEL' key or the cursor keys for
each of these fonts and you will see what I mean) so the programme grew
to become a UTILITY to, not only give you the ASCII value of each key
pressed, but to display its `character output' as well.
This programme is also a good example of setting a number of `Fonts'
in memory utilising simple calls that change them instantly.
**** CAUTION ****
THIS PROGRAMME WILL NOT RUN ON THIS DISC UNLESS YOU FIRST DRAG IT'S ICON
OUT OF THE DISC'S WINDOW AND THEN CLOSE IT (THE DISC'S WINDOW) BEFORE
ATTEMPTING TO RUN IT. IF YOU MOVE THE PROGRAMME TO ANOTHER DISC PLEASE
ENSURE THAT THE GRAPHICS AND DISKFONT BITMAPS ARE IN THAT DISC'S LIB
DIRECTORY, AND THAT pc.font(DIR) AND pc.font.font ARE IN THE FONTS
DIRECTORY.
THE EASIEST WAY TO DO THAT IS TO COPY ALL THE BMAPS FROM THE LIBS
DIRECTORY ON THIS DISC TO YOUR NEW DISC, ALONG WITH THE ABOVE FONTS TO
IT'S FONT DIRECTORY. TO DO THAT, USE THE SYSTEM DESCRIBED ABOVE.
*****************************************************************************
ChangePointer
(Requires Sys1.2,intuition.bmap,graphics.bmap and the icon.bmap)
Have you ever sat down with a bit of graph paper, sorted out
a piece that is 16 sections wide by 15 sections deep, then filled in
these sections to draw what will become the new design for your MOUSE
Pointer? Once you have done that you then have to work out the binary
representations of what you've drawn into two separate numbers, both
covering the entire sixteen sections but representing four different
colours(Three colours and invisible). These numbers are worked out by
including one colour in both numbers, one colour in the left number and
the other in the right number. Once you've done that you only have to do
it 14 (thats FOURTEEN) more times and then convert all those numbers to
HEX. Then all thats left to do is work out how to programme it so that
it will actually change your Pointer.
Easy!!
Garbage it's easy.
It's a mongrel job.
But imagine how good your programme could look with that special
pointer for a particular job. Let's say you wanted someone to draw a line
with the pointer and you could redesign it to be a pencil from within
your programme, or you wanted them to push a button so you redesign your
pointer to be a hand with an outstretched finger.
Well I had such an occasion, so I sat down with a piece of graph
paper and I sorted out a section that was 16 sections wide and fifteen
sections deep and I........................
You get the picture.
Then I thought,
`Here I am with this marvelous piece of machinery and I'm doing all
this manual work. I must be crazy. Surely my Amiga can do it for me?'
So I developed `ChangePointer'(it's a catchy name isn't it).
I had some problems. Firstly, the computer will give me a STRING
representation of a HEX number by converting with HEX$(), but I can find
no way of obtaining a HEX Number that is not a STRING. This explains all
the disc access while the programme is running because I had to create a
Sequential File and then READ it to convert the STRING'ed HEX numbers to
plain HEX Numbers. I may have been able to `POKE' strings as DATA instead
of numbers but I'm not too sure that would work.
Secondly, it seems that the Intuition Library is not too thrilled
with Basic fooling around with the pointer and, although I've had no
problems with any programmes I,ve changed the pointer in, but this
programme sometimes bogs down. I can only assume it's this area that's
causing the problem because the programme seems to be very well behaved
in all other areas.
When you first startup, you will be presented with a graph
thats, you guessed it, 16 sections wide and 15 sections deep. Underneath
that is a colour bar containing four colours that are the same colours
that your pointer will be. Beneath that are your `Command' boxes.
The pointer will at first disappear and, when it reappears, it will
be white. You can now use the pointer, with the left MOUSE button to fill
in the squares, choosing the colours from the colour bar. As you choose
a new colour, the pointer will change to that colour.
Once you have finished your creation and have selected `SAVE', the
pointer will change to `WAIT' and your DATA will be printed on the left
section of the screen. You will then be asked to `Select your Hot Spot'.
That's the position which is the active part when you `click' the MOUSE.
Now you will be asked to name your DATA file, to which the programme
will append `.DPtr'.
You will then be given the choice of either a `DATA' or a `PROG'
file.
A `DATA' file is just that. The file will contain your DATA
statements and the `OffSet' positions for your Hot Spot.
A `PROG' file is an entire programme that contains all the necessary
commands to change your pointer and, if you run it (by CLICKing on the
DISPLAY box), it will make its own screen, across which it will put seven
bands of colour and display YOUR pointer. This gives you the opportunity
to see how YOUR pointer looks over different colours.
If you do `DISPLAY' your pointer, the programme passes control to
that programme and `ChangePointer'(catchy) is no longer in memory.
Now, whether you create a `DATA' file or a `PROG' file, the pointer
will change to the one you designed anyway. It does this by creating it's
own `DATA' file, called `Display1.Ptr' or `Display2.Ptr' etc (up to 6),
reading it by MERGEing it to this programme. It then puts the name of your
pointer into one of the six boxes on the left of the screen.
You can call any of the pointers you create (up to six at a time),
simply by clicking on it's box.
To use the pointer you create, in one of your own programmes, you
will have to do one of two things.
1. Begin by creating a `PROG' file and `DISPLAY'ing it. This will
give you all the necessary code you will need to change the pointer, so
you can use it as the basis for your programme, or copy the bits you
need into your programme.
2. Create a `DATA' file and, when you load your programme, MERGE
your `DATA' file on to the end. You will have to remove some comments
that are also on the file and reference your OffSets to your `Change'
routine.
In all probability, you will need to load at least one `PROG' file
to obtain the code you will need. You will find that it is heavily
commented. All these comments can be deleted.
If you intend to use more than one POINTER in your programme, it
would probably be interesting to LIST `ChangePointer' (I like it), and
see just what I've done in there.
One word of warning. These files are not initially saved as
PROGRAMME files so you cannot start them by clicking on the icons. You
will have to either MERGE them to the end of a `loaded' Basic programme
or Open Basic and type `load "MyProgramme.DPtr"(Where MyProgramme is the
name you gave it). Once it is loaded simply `SAVE' it and then the ICON
will work.
The reason that each file is appended with either `.DPtr' or `.Ptr'
is one of convenience.
Once you have finished working with the files, or you simply no
longer require them, you can use the pattern matching ability of the CLI
to delete all these files in one go.
To DELETE just the `Display1.Ptr' files enter the CLI and type...
DELETE #?.Ptr
You can remove just `YOUR' files by typing
DELETE #?.DPtr
Or you can remove the lot by typing
DELETE #?Ptr
I have not finished with this programme, in fact it is only two days
old at the time of writing. I have quite a few improvements in mind, and
some obvious bugs to elliminate.
When I have totally revised it, I will resubmit it along with a
version written in `C'.
One CAUTION: Take it easy whilst the pointer is actually changeing.
It seems that this is when the problem mentioned above occurs.
Have fun...
*****************************************************************************
THOUGHT-POWER
(requires Sys 1.2, graphics.bmap & diskfont.bmap)
Thought Power is a game similar to Master Mind that I have written
for the Amiga.
It uses colours, rather than numbers, but the principle is the
same. The Computer chooses four colours, at random, from a palette of
eight, and you have to guess, through a series of elliminations, which
colours they are and which order the Computer has them in.
The game is very easy to follow. You use the MOUSE to choose your
colours and the Computer fills in the squares. Once you have filled four
squares you have had one go. The Computer then tells you how many colours
you got right, and in the right place, and how many colours you got right
but in the wrong place. At the end of each row of four squares are four
little squares. The ones filled in white indicate right colours in the
right place and the ones filled in purple indicate right colours in the
wrong
place. If there are any blanks, then there are that many colours, in your
selections, that are alltogether wrong.
The position of the white and purple squares is not relative to
the positions of your colours. They simply tell you how you went. You have
to work out which ones are the right ones.
The Programme uses the `Menu' function to allow you the choice of
using just the white indicators. This makes the game a little harder but
still possible.
As the programme is `memory intensive', a CLEAR statement is
required prior to each replay. This caused a few headaches, with the
`Best go so far' and the `Menu Choice' features, as each time the CLEAR
statement is invoked, all variables are reset.
The way I got around this problem was to `PSET' two points on the
screen and, subsequent to the CLEAR command, read those points with the
POINT (x,y) function to reset the variables.
I did not include any sounds as I'm only capable of fairly simple
beeps and twitters. I'm not sure that it needs any but over to you. Feel
free to change whatever you like. If you come up with any improvements
let me know.
************************************************************************
I hope you have some fun with the programmes.
Gary O'Connor
Penrith.
~~~~~~~~~~~~~~~~~~~~~~~~~~ END OF GAMES-INTRO ~~~~~~~~~~~~~~~~~~~~~~~~~~~